function Clock() {
	var canvas = document.getElementById("canvas")
	this.cxt = canvas.getContext('2d')
	canvas.width=600;
	canvas.height=100;
	this.r = 100/20-1;
	this.cxt.fillStyle="#ddd"
	this.cxt.fillRect(0,0,500,100)
}

Clock.prototype.draw = function(num, index) {
	this.cxt.fillStyle="#000"
	for (var i=0; i<digit[num].length; i++) {
		for(var j=0; j<digit[num][i].length; j++) {
			if (digit[num][i][j]==1){
				this.cxt.beginPath();
				this.cxt.arc(index*7*2*(this.r+1)+j*2*(this.r+1)+(this.r+1),i*2*(this.r+1)+(this.r+1), this.r, 0, Math.PI*2);
				this.cxt.closePath();
				this.cxt.fill()
			}
		}
	}
}

Clock.prototype.getDate = function(){
	var temp = /(\d)(\d):(\d)(\d):(\d)(\d)/.exec(new Date());
	var data=[]
	//时：分：秒
	data.push(temp[1],temp[2],10,temp[3],temp[4],10,temp[5],temp[6])
	canvas.height = 100;
	for (var i=0;i<data.length;i++){
		clock.draw(data[i], i);
	}
}

var clock = new Clock();
//clock.getDate();
//for (var i=0;i<5;i++){
	//clock.draw(i, i);
//}
setInterval(function(){
	clock.getDate();
})
